﻿namespace LogManager.Utils.Xml
{
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Xml.Schema;

    /// <summary>
    /// TODO: Update summary.
    /// </summary>
    public class XsdValidationException : Exception
    {
        public IEnumerable<ValidationEventArgs> ValidationErrors;

        public XsdValidationException(string message, IEnumerable<ValidationEventArgs> validationErrors)
            : base(FormatMessage(message, validationErrors))
        {
            this.ValidationErrors = validationErrors;
        }

        private static string FormatMessage(string baseMessage, IEnumerable<ValidationEventArgs> validationErrors)
        {
            var sb = new StringBuilder();
            sb.AppendLine(baseMessage);
            foreach (var error in validationErrors)
            {
                sb.AppendLine(error.Message);
            }
            return sb.ToString();
        }
    }
}
